@echo off

rem
rem Installation script for CK packages.
rem
rem See CK LICENSE.txt for licensing details.
rem See CK Copyright.txt for copyright details.
rem
rem Developer(s): Grigori Fursin, 2016-2017
rem

rem PACKAGE_DIR
rem INSTALL_DIR

if "%CAFFE_BUILD_PYTHON%" == "ON" (
  echo.
  echo You are compiling Caffe with Python support!
  echo To use it you need to set up CK env as following ^(after installation^)^:
  echo.
  echo $ ck virtual env --tags=lib,caffe
  echo $ ipython
  echo.
  set /p id="Press enter to continue"
)

echo **************************************************************
echo Preparing vars for Caffe ...

set EXTRA_FLAGS=

if "%CK_VIENNACL_DEBUG%" == "ON" (
  set EXTRA_FLAGS=%EXTRA_FLAGS% -DVIENNACL_DEBUG_ALL
)

set CK_CC_FLAGS_FOR_CMAKE=%EXTRA_FLAGS%
set CK_CXX_FLAGS_FOR_CMAKE=%EXTRA_FLAGS%

rem set CK_CXX_FLAGS_FOR_CMAKE=
set CK_CXX_FLAGS_ANDROID_TYPICAL=

set VIENNACL_HOME=%CK_ENV_LIB_VIENNACL%
set CLBlast_DIR=%CK_ENV_LIB_CLBLAST%

set CK_CMAKE_EXTRA=%CK_CMAKE_EXTRA% ^
 -DBLAS=%BLAS_TYPE% ^
 -DCPU_ONLY:BOOL=%CPU_ONLY% ^
 -DUSE_OPENMP:BOOL=0 ^
 -DUSE_FFT:BOOL=%USE_FFT% ^
 -DUSE_GREENTEA:BOOL=%USE_GREENTEA% ^
 -DUSE_CUDA:BOOL=%USE_CUDA% ^
 -DUSE_CUDNN:BOOL=%USE_CUDNN% ^
 -DUSE_LIBDNN:BOOL=%USE_LIBDNN% ^
 -DUSE_CLBLAS:BOOL=%USE_CLBLAS% ^
 -DUSE_CLBLAST:BOOL=%USE_CLBLAST% ^
 -DUSE_ISAAC:BOOL=%USE_ISAAC% ^
 -DUSE_NCCL:BOOL=%USE_NCCL% ^
 -DUSE_INTEL_SPATIAL=%USE_INTEL_SPATIAL% ^
 -DUSE_INDEX64:BOOL=%USE_INDEX64% ^
 -DUSE_LMDB=%USE_LMDB% ^
 -DUSE_LEVELDB=OFF ^
 -DUSE_HDF5=ON ^
 -DDISABLE_DEVICE_HOST_UNIFIED_MEMORY=%DISABLE_DEVICE_HOST_UNIFIED_MEMORY% ^
 -DDISABLE_DOUBLE_SUPPORT=%DISABLE_DOUBLE_SUPPORT% ^
 -DUSE_PREBUILT_DEPENDENCIES=OFF ^
 -DBUILD_SHARED_LIBS:BOOL=%CMAKE_BUILD_SHARED_LIBS% ^
 -DBUILD_python=%CAFFE_BUILD_PYTHON% ^
 -DBUILD_matlab:BOOL=%BUILD_MATLAB% ^
 -DGFLAGS_INCLUDE_DIR="%CK_ENV_LIB_GFLAGS_INCLUDE%" ^
 -DGFLAGS_LIBRARY="%CK_ENV_LIB_GFLAGS_LIB%\gflags.lib" ^
 -DGLOG_INCLUDE_DIR="%CK_ENV_LIB_GLOG_INCLUDE%" ^
 -DGLOG_LIBRARY="%CK_ENV_LIB_GLOG_LIB%\glog.lib" ^
 -DLMDB_INCLUDE_DIR="%CK_ENV_LIB_LMDB_INCLUDE%" ^
 -DLMDB_LIBRARIES="%CK_ENV_LIB_LMDB_LIB%\lmdb.lib" ^
 -DCMAKE_BUILD_TYPE:STRING=%CMAKE_CONFIG% ^
 -DPROTOBUF_DIR="%CK_ENV_LIB_PROTOBUF_HOST%\cmake" ^
 -DHDF5_ROOT_DIR="%CK_ENV_LIB_HDF5%\cmake" ^
 -DHDF5_INCLUDE_DIRS="%CK_ENV_LIB_HDF5_INCLUDE%" ^
 -DHDF5_LIBRARIES="%CK_ENV_LIB_HDF5_LIB%\hdf5.lib" ^
 -DHDF5_HL_LIBRARIES="%CK_ENV_LIB_HDF5_LIB%\hdf5_hl.lib" ^
 -DOpenBLAS_INCLUDE_DIR="%CK_ENV_LIB_OPENBLAS_INCLUDE%" ^
 -DOpenBLAS_LIB="%CK_ENV_LIB_OPENBLAS_LIB%\%CK_ENV_LIB_OPENBLAS_STATIC_NAME%" ^
 -DBoost_ADDITIONAL_VERSIONS="1.62" ^
 -DBoost_NO_SYSTEM_PATHS=ON ^
 -DBOOST_ROOT=%CK_ENV_LIB_BOOST% ^
 -DBOOST_INCLUDEDIR="%CK_ENV_LIB_BOOST_INCLUDE_CYGWIN%" ^
 -DBOOST_LIBRARYDIR="%CK_ENV_LIB_BOOST_LIB%" ^
 -DBoost_INCLUDE_DIR="%CK_ENV_LIB_BOOST_INCLUDE_CYGWIN%" ^
 -DBoost_LIBRARY_DIR="%CK_ENV_LIB_BOOST_LIB%" ^
 -DOpenCV_DIR="%CK_ENV_LIB_OPENCV%" ^
 -DOpenCV_LIB_PATH="%CK_ENV_LIB_OPENCV_LIB%" ^
 -DOPENCL_LIBRARIES="%CK_ENV_LIB_OPENCL_LIB%\OpenCL.lib" ^
 -DOPENCL_INCLUDE_DIRS="%CK_ENV_LIB_OPENCL_INCLUDE%" ^
 -DCLBlast_DIR="%CK_ENV_LIB_CLBLAST%" ^
 -DCLBLAST_LIB="%CK_ENV_LIB_CLBLAST_LIB%" ^
 -DCLBLAST_INCLUDE="%CK_ENV_LIB_CLBLAST_INCLUDE%" ^
 %CK_CMAKE_EXTRA% 

rem  -DHDF5_DIR="%CK_ENV_LIB_HDF5%\cmake" ^

exit /b 0
